#ifndef PLUGIN_EVENTRECORD_H
#define PLUGIN_EVENTRECORD_H

#include "../../IPlugin.h"
#include "ui_plugin_eventrecord.h"
#include "eventrecord_table.h"

QT_BEGIN_NAMESPACE
namespace Ui
{
    class plugin_eventrecord;
}
QT_END_NAMESPACE

class plugin_eventrecord : public IPlugin
{
    Q_OBJECT
    Q_INTERFACES(IPlugin)
    Q_PLUGIN_METADATA(IID "com.example.IPlugin/1.0" FILE "plugin_eventrecord.json")

public:
    QString pluginName() const override { return "plugin_eventrecord"; }
    QString version() const override { return "1.0"; }

    QWidget *createUI(QWidget *parent) override
    {
        pluginWidget = new QWidget(parent);
        plugin_eventrecord_ui = new Ui::plugin_eventrecord();
        plugin_eventrecord_ui->setupUi(pluginWidget);
        return pluginWidget;
    }

    void sendMessageToPlugin(const QString &msg) override;

    ~plugin_eventrecord()
    {
        delete plugin_eventrecord_ui;
    }

private:
    Ui::plugin_eventrecord *plugin_eventrecord_ui = nullptr;
    QWidget *pluginWidget;
    eventrecord_table mEventRecordTable;
    void processJsonCommand(const QString &jsonStr);
    void initUi();
};

#endif // PLUGIN_EVENTRECORD_H